/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.games;

import org.ceroproject.SortableCollection;

/**
 * A round is a part of a game. For example, implement this into a bet round and
 * another one into a play round. Add these rounds to the Game to have the game
 * going alright. A round stops when one of the round stop conditions has been
 * filled.
 * 
 * @author Telem
 */
public interface Round {

	/**
	 * Starts the round.
	 */
	void start(Game game);

	/**
	 * Adds a condition to stopping the round
	 * 
	 * @param condition
	 *            the condition which, when fulfilled, shall stop the round
	 */
	void addRoundStopCondition(StopCondition condition);

	/**
	 * Removes a condition to stopping the round
	 * 
	 * @param condition
	 *            the condition which shall not stop the round anymore
	 */
	void removeRoundStopCondition(StopCondition condition);

	/**
	 * Registers this action, which will then be take care of by the round loop
	 * 
	 * @param act
	 *            The Action to register
	 */
	void registerAction(Action act);

	/**
	 * Adds an ActionRule to this round
	 * 
	 * @param rule
	 *            the rule to add in this round
	 */
	boolean addActionRule(ActionRule rule);

	/**
	 * Removes an ActionRule from this round
	 * 
	 * @param rule
	 *            the rule to remove from this round
	 */
	boolean removeActionRule(ActionRule rule);
	
	/**
	 * Adds a listener to this round
	 * 
	 * @param listener
	 *            the new listener to this round
	 */
	void addRoundListener(RoundListener listener);

	/**
	 * Removes a listener from this round
	 * 
	 * @param listener
	 *            the listener to remove
	 */
	void removeRoundListener(RoundListener listener);

	/**
	 * The list of subrounds in this round
	 * 
	 * @return The list of subrounds in this round
	 */
	SortableCollection<Round> getSubRounds();

	/**
	 * Adds an action listener to this round
	 * 
	 * @param listener
	 *            the listener to add
	 * @return whether the listener has been added or not
	 */
	boolean addActionListener(ActionListener listener);

	/**
	 * Removes an action listener from this round
	 * 
	 * @param listener
	 *            the listener to remove
	 * @return whether the listener has been removed or not
	 */
	boolean removeActionListener(ActionListener listener);

	public String toString();
}
